package com.zb.jsp.utils;

import java.util.ArrayList;
import java.util.List;

public class StringUtil {

	/**
	 * 判断输入字符串是否为空或者null
	 * 
	 * @param obj
	 *            需要判断的字串
	 * @return 时空或null返回true否则返回false
	 */
	public static boolean isNullOrEmpty(Object obj) {
		boolean emptyOrNullFlg = false;

		if (obj == null || "".equals(obj)) {
			emptyOrNullFlg = true;
		}
		return emptyOrNullFlg;
	}

	/**
	 * 把List转化为String
	 * 
	 * @param objList
	 *            目标List
	 * @return 转化好的String值
	 */
	public static String chgList2String(List objList) {
		String objStr = "";
		if (objList != null && objList.size() > 0) {
			objStr = objStr + objList.get(0);
			for (int i = 1; i < objList.size(); i++) {
				objStr = objStr + "," + objList.get(i);
			}
		}

		return objStr;
	}
	
	/**
	 * 把String 转化为 Lisst
	 * 
	 * @param String items
	 *            要转化的字串
	 * @return List转化好的List值
	 */
	public static List chgString2List(String items) {
		List itemsList = new ArrayList();
		if(!isNullOrEmpty(items)){
			String[] itemArray = items.split(",");
			for(String itemRange:itemArray){
				itemsList.add(itemRange);
			}			
		}
		return itemsList;				
	}
	
}
